//
//  MyRedenvelopesCell.m
//  NewPro
//
//  Created by 何荧红 on 2019/6/21.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "MyRedenvelopesCell.h"

@interface MyRedenvelopesCell ()
@property (weak, nonatomic) IBOutlet UILabel *SubMoney;
@property (weak, nonatomic) IBOutlet UILabel *money;
@property (weak, nonatomic) IBOutlet UILabel *nametitle;
@property (weak, nonatomic) IBOutlet UILabel *Canused;
@property (weak, nonatomic) IBOutlet UILabel *timeLab;
@property (weak, nonatomic) IBOutlet UILabel *useLabel;
@property (weak, nonatomic) IBOutlet UIImageView *isNewed;
@property (weak, nonatomic) IBOutlet UIImageView *ispassed;

@end



@implementation MyRedenvelopesCell

- (void)setCellType:(NSInteger)CellType{
    _CellType = CellType;
    if (_CellType == 1) {
        self.useLabel.hidden = NO;
        self.ispassed.hidden = YES;
        
        self.SubMoney.textColor = [UIColor colorWithHexString:@"FF1111"];
        self.money.textColor = [UIColor colorWithHexString:@"FF1111"];
        self.nametitle.textColor = [UIColor colorWithHexString:@"333333"];
        self.Canused.textColor = [UIColor colorWithHexString:@"666666"];
        self.timeLab.textColor = [UIColor colorWithHexString:@"333333"];
        self.useLabel.text = @"去使用";
        
    }else if (_CellType == 2){
        self.useLabel.hidden = NO;
        self.ispassed.hidden = YES;
        
        self.SubMoney.textColor = [UIColor colorWithHexString:@"FF1111" alpha:0.8];
        self.money.textColor = [UIColor colorWithHexString:@"FF1111" alpha:0.8];
        self.nametitle.textColor = [UIColor colorWithHexString:@"333333" alpha:0.8];
        self.Canused.textColor = [UIColor colorWithHexString:@"666666" alpha:0.8];
        self.timeLab.textColor = [UIColor colorWithHexString:@"333333" alpha:0.8];
        self.useLabel.backgroundColor = [UIColor colorWithHexString:@"B3B3B3"];
        self.useLabel.text = @"已使用";
        
    }else if (_CellType == 3){
        self.useLabel.hidden = YES;
        self.ispassed.hidden = NO;
        
        self.SubMoney.textColor = [UIColor colorWithHexString:@"FF1111" alpha:0.8];
        self.money.textColor = [UIColor colorWithHexString:@"FF1111" alpha:0.8];
        self.nametitle.textColor = [UIColor colorWithHexString:@"333333" alpha:0.8];
        self.Canused.textColor = [UIColor colorWithHexString:@"666666" alpha:0.8];
        self.timeLab.textColor = [UIColor colorWithHexString:@"333333" alpha:0.8];
        
    }
}
- (void)setModel:(MyRedenvelopesModel *)model{
    _model = model;
    if (_model) {
        NSDate *data = [NSDate date];
        NSDateFormatter *allfor = [[NSDateFormatter alloc]init];
        allfor.dateFormat = @"yyyy.MM.dd";
        
        NSDate *Create = [NSDate dateWithTimeIntervalSince1970:[_model.createTime integerValue]/1000.0];
        NSDate *End = [NSDate dateWithTimeIntervalSince1970:[_model.expireTime integerValue]/1000.0];
        if ([[allfor stringFromDate:data] isEqualToString:[allfor stringFromDate:Create]]) {
            self.isNewed.hidden = NO;
        }else{
            self.isNewed.hidden = YES;
        }
        self.money.text = [NSString stringWithFormat:@"%@",_model.amount];
        self.nametitle.text = _model.name;
        self.Canused.text = _model.comment;
        self.timeLab.text = [NSString stringWithFormat:@"限%@-%@使用",[allfor stringFromDate:Create],[allfor stringFromDate:End]];
    }
}
- (void)setFrame:(CGRect)frame{
//    frame.origin.y += 15;
    frame.origin.x += 13;
    frame.size.width -= 28;
//    frame.size.height -= 15;
    [super setFrame:frame];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;
    self.layer.shadowOffset = CGSizeMake(1, 4);
    self.layer.shadowColor = [UIColor colorWithHexString:@"000000"].CGColor;
    self.layer.shadowOpacity = 0.1f;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
